<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- 引入样式 -->
<!--    <link rel="stylesheet" href="../elementUI.css">-->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../base.css">
    <title>登录</title>
</head>
<body>
<div id="app">
    <el-row>
        <el-col :span="4" :offset="10">
            <el-form label-width="80px">
                <el-form-item label="账号">
                    <el-input v-model="username" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input v-model="password" type="password" size="mini"></el-input>
                </el-form-item>
            </el-form>
        </el-col>
    </el-row>
    <el-row>
        <el-col :span="4" :offset="13">
            <el-button type="success" @click="onSubmit">登录</el-button>
        </el-col>
    </el-row>
</div>


</body>
<!-- 先引入 Vue -->
<script src="../vue.js"></script>
<!-- 引入组件库 -->
<script src="../elementUI.js"></script>
<!-- vue ajax插件 -->
<script src="../axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            username: '',
            password: ''
        },
        methods: {
            onSubmit() {
                var that = this;
                axios.defaults.withCredentials = true;
                axios.post('http://39.105.59.232/register/check', {
                    username: that.username,
                    password: that.password
                })
                    .then(function (response) {
                        if (response.data.code == 200) {
                            window.open("index.html", "_self");
                        } else {
                            that.$alert("登录失败", "提示");
                        }
                    })
            },
        }
    })
</script>
</html>